//
//  ViewController.m
//  26-Masonry
//
//  Created by dllo on 16/8/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//1.使用Masonry不用给初始frame
    UIView *view = [UIView new];
////    添加约束前，需要把视图添加到俯视图上
    [self.view addSubview:view];
    view.backgroundColor = [UIColor redColor];
[view mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.top.bottom.mas_equalTo(0);
}];
    UIView *view1 = [UIView new];
    [self.view addSubview:view1];
    view1.backgroundColor = [UIColor blueColor];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.5f);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.3333333f);
        make.centerX.centerY.mas_equalTo(0);
//        make.centerX.mas_equalTo(0);
        make.height.width.mas_equalTo(100);
//        make.width.mas_equalTo(100);
    }];

    
    UIView *view2 = [UIView new];
    [self.view addSubview:view2];
    view2.backgroundColor = [UIColor orangeColor];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(view1);
        make.top.mas_equalTo(view1.mas_bottom).mas_offset(10);
        make.centerX.mas_equalTo(view1);
    }];
    
    
   
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
